/*
https://leetcode.cn/problems/pascals-triangle-ii/submissions/584674541/?envType=problem-list-v2&envId=dynamic-programming
119. 杨辉三角 II
*/
class Solution {
public:
    vector<int> getRow(int numRows) {
        if(numRows==1) return {{1,1}};
        if(numRows==0) return {1};
        ++numRows;
        vector<vector<int>>dp(numRows);
        for(int i=0;i<=numRows;i++){
            dp.resize(i+1);
            dp[i].resize(i+1, 1);
        }
        for(int i=2;i<numRows;++i){
            for(int j=1;j<i;++j){
                dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
            }
        }
        return dp[numRows-1];
    }
};